package br.com.viewcar.util;

import javax.servlet.http.HttpServletRequest;

public class MobileUtil {

	public static final boolean isMobile(HttpServletRequest request) {

		String userAgent = request.getHeader("user-agent").toLowerCase();
		String accept = request.getHeader("accept").toLowerCase();

		if (accept.contains("text/vnd.wap.wml") || accept.contains("application/vnd.wap.xhtml+xml")) {
			return true;
		}

		if (userAgent.contains("ipod")
				|| userAgent.contains("iphone")
				|| userAgent.contains("android")
				|| userAgent.contains("blackberry")
				|| userAgent.contains("opera mini")
				|| userAgent.contains("mmp")
				|| userAgent.contains("symbian")
				|| userAgent.contains("smartphone")
				|| userAgent.contains("midp")
				|| userAgent.contains("vodafone")
				|| userAgent.contains("o2")
				|| userAgent.contains("pocket")
				|| userAgent.contains("kindle")
				|| userAgent.contains("mobile")
				|| userAgent.contains("pda")
				|| userAgent.contains("psp")
				|| userAgent.contains("treo")
				|| userAgent.contains("wap")) {

			return true;
		}
		return false;
	}
}